package homework;

public class DepositCard {
    private String account;
    private double balance;

    public DepositCard(String account, double balance) {
        this.account = account;
        this.balance = balance;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
    public void withdraw(double money){
        if(money<0){
            System.out.println("取款金额不能为负数");
        }else if (money>balance){
            System.out.println("余额不足");
        }else {
            balance-=money;
            System.out.println("取款成功，当前余额：" + balance);
        }
    }
    public void save(double money){
        if (money<0){
            System.out.println("存款金额不能为负数");
        }else {
            balance+=money;
            System.out.println("存款成功，当前余额：" + balance);
        }
    }
    public String getInfo(){
        return "你的账户为"+account+",现有余额为"+balance;
    }
}
